﻿//-----------------------------------------------------------------------
// <copyright file="UnitTest1.cs" company="上海Zoomla!逐浪CMS团队">
// 版权所有:🏢江西逐浪软件科技有限公司  🏅🏅🏅20年专注研发==>商城|ERP|字库|高端门户与人工智能 
// Website:🚀www.z01.com 
// Contact:☎ 13177777714  😎 wechat: zoomla 
// Effect: 🔧 单元测试-分页
// Create: ⏰2020年09月14日,07:48
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SportsStore.Domain.Abstract;
using SportsStore.Domain.Entities;
using SportsStore.WebUI.Controllers;


namespace SportsStore.UnitTests
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void Can_Pageinate()
        {
            //准备
            Mock<IProductsRepository> mock = new Mock<IProductsRepository>();
            mock.Setup(m => m.Products).Returns(new Product[]{
                new Product { ProductID = 1, Name = "P1" },
                new Product { ProductID = 2, Name = "P2" },
                new Product { ProductID = 3, Name = "P3" },
                new Product { ProductID = 4, Name = "P4" },
                new Product { ProductID = 5, Name = "P5" },
            });
            ProductController controller = new ProductController(mock.Object);
            controller.PageSize = 3;

            //动作
            //IEnumerable<Product> result = (IEnumerable<Product>)controller.List(2).Model;

            //断言
            //Product[] prodArray = result.ToArray();
            //Assert.IsTrue(prodArray.Length == 2);
            //Assert.AreEqual(prodArray[0].Name, "P4");
            //Assert.AreEqual(prodArray[1].Name, "P5");
        }
    }
}
